
from django.conf.urls.defaults import patterns, url
from django.views.generic import TemplateView
from rest_framework.urlpatterns import format_suffix_patterns
from cvirt.manager.view import host,cluster,vm,monitor,activities,datacenter,network,backup
from cvirt.manager.views import TreeListView
from cvirt.manager.view.bookmark import ShortcutInfo, ShortcutList
from cvirt.manager.view import storage, image, security_rule, proposal
from cvirt.manager.models import Template
from cvirt.manager.view import globalconfig
from cvirt.manager.view import platform
from cvirt.manager.view.license import License
from cvirt.manager.view.fixedip import FixedipList, FixedipInfo
from cvirt.manager.view.user import Users, UserInfo
from cvirt.manager.view.client import Client

urlpatterns = patterns('',
    url(r'^tree_list$',TreeListView.as_view()),
)
# activities

urlpatterns+= patterns("activities",
    url(r'^activities$',activities.ActivitiesView.as_view()),
    url(r'^activities/(?P<action>[^/]+)',activities.ActivitiesView.as_view())
)

# monitor
urlpatterns += patterns('monitor',
    url(r'^monitor/do_graph$',monitor.HostMonitorGraphs.as_view()),
    url(r'^monitor$',monitor.HostMonitorGraphs.as_view()),
    url(r'^monitor/graph$',monitor.HostMonitorGraphs.as_view()),
    url(r'^monitor/(?P<hostname>[^/]+)$',monitor.HostMonitorGraphs.as_view()),
)
# datacenter
urlpatterns += patterns('datacenter',
    url(r'^datacenters$',datacenter.DatacenterView.as_view()),
    url(r'^datacenters/(?P<action>[^/]+)$',datacenter.DatacenterView.as_view()),
    url(r'^datacenter/(?P<pk>[0-9]+)/$',datacenter.DatacenterDetail.as_view()),
    url(r'^datacenter/(?P<pk>[0-9]+)/(?P<action>[^/]+)$',datacenter.DatacenterDetail.as_view()),
    url(r'^datacenter/(?P<pk>[0-9]+)/events/(?P<action>[^/]+)$',datacenter.EventListView.as_view()),
)
#host
urlpatterns += patterns("host",
    url(r'^hosts/$', host.HostList.as_view()),
    url(r'^hosts/(?P<action>[^/]+)/$', host.HostList.as_view()),
    url(r'^host/(?P<pk>[0-9]+)/$', host.HostInfo.as_view()),
    url(r'^host/(?P<pk>[0-9]+)/(?P<action>[^/]+)$', host.HostInfo.as_view()),
)

# vm
urlpatterns += patterns("vm",
    url(r"^vms/$",vm.VMsLIst.as_view()),
    url(r"^vms/(?P<action>[^/]+)$",vm.VMsLIst.as_view()),
    url(r"^vm/(?P<pk>[0-9]+)/$",vm.VMInfo.as_view()),
    url(r"^vm/(?P<pk>[0-9]+)/(?P<action>[^/]+)$",vm.VMInfo.as_view()),
    # url(r"^vm/(?P<action>[^/]+)$",vm.VMInfo.as_view()),
)

#storage
urlpatterns += patterns('storage',
    url(r"^storages/$",storage.StorageListView.as_view()),
    url(r"^storages/(?P<action>[^/]+)$",storage.StorageListView.as_view()),
    url(r"^storage/(?P<pk>[0-9]+)/$",storage.StorageDetailView.as_view()),
    url(r"^storage/(?P<pk>[0-9]+)/(?P<action>[^/]+)$",storage.StorageDetailView.as_view()),
)

#security_group
urlpatterns += patterns('security_group',
    url(r'^security_groups$',security_rule.SecurityGroupView.as_view()),
    url(r'^security_groups/(?P<action>[^/]+)$', security_rule.SecurityGroupView.as_view()),
    url(r"^security_groups/(?P<pk>[0-9]+)/(?P<action>[^/]+)$",security_rule.SecurityGroupView.as_view()),
)

#security_rule
urlpatterns += patterns('security_rule',
    url(r'^security_rules$',security_rule.SecurityRuleView.as_view()),
    url(r'^security_rules/(?P<action>[^/]+)$', security_rule.SecurityRuleView.as_view()),
)

# cluster
urlpatterns += patterns("cluster",
    url(r"^clusters/$",cluster.ClusterList.as_view()),
    url(r"^clusters/(?P<action>[^/]+)$",cluster.ClusterList.as_view()),
    url(r"^cluster/(?P<pk>[0-9]+)/$",cluster.ClusterInfo.as_view()),
    url(r"^cluster/(?P<pk>[0-9]+)/(?P<action>[^/]+)$",cluster.ClusterInfo.as_view()),
)

# platform
urlpatterns += patterns("platform",
    url(r"^platform$",platform.PlatformView.as_view()),
    url(r"^platform/(?P<action>[^/]+)$",platform.PlatformView.as_view())
)

#template
urlpatterns += patterns("template",
     url(r'^templates$',image.TemplateInfo.as_view()),
     url(r'^templates/(?P<action>[^/]+)$',image.TemplateInfo.as_view()),
     url(r'^template/(?P<pk>[0-9]+)/(?P<action>[^/]+)$', image.TemplateInfo.as_view()),
)

# others
urlpatterns += patterns('',
    url(r"^networks/$",network.Networks.as_view()),
    url(r"^networks/(?P<action>[^/]+)$",network.Networks.as_view()),
    url(r"^network/(?P<pk>[0-9]+)/$",network.NetworkDetail.as_view()),
    url(r"^network/(?P<pk>[0-9]+)/(?P<action>[^/]+)$",network.NetworkDetail.as_view()),
)


urlpatterns += patterns('',
    url(r"^backups$",backup.Backupstrategys.as_view()),
    url(r"^backups/status$",backup.Backupstrategys.as_view()),
    url(r"^backup_strategies$",backup.Backupstrategys.as_view()),
    url(r'^backup_strategies/(?P<action>[^/]+)$', backup.Backupstrategys.as_view()),
)

urlpatterns += patterns('',
    url(r'^proposals/$', proposal.ProposalList.as_view()),
    url(r'^proposals/(?P<action>[^/]+)$', proposal.ProposalList.as_view()),
    url(r'^proposal/(?P<pk>[0-9]+)/$', proposal.ProposalInfo.as_view()),
    url(r'^proposal/(?P<pk>[0-9]+)/(?P<action>[^/]+)$', proposal.ProposalInfo.as_view()),
)


urlpatterns += patterns('',
    # url(r'^dropdown/(?P<item>[^/]+)$', dropDown.ItemList.as_view())
    url(r'^globalconfigs$', globalconfig.GlobalConfigList.as_view()),
    url(r'^globalconfigs/(?P<action>[^/]+)$', globalconfig.GlobalConfigList.as_view())
)


urlpatterns += patterns('',
    url(r'^shortcuts/$',ShortcutList.as_view()),
    url(r'^shortcuts/(?P<action>[^/]+)$',ShortcutList.as_view()),
    url(r'^shortcut/(?P<action>[^/]+)$',ShortcutInfo.as_view()),
    url(r'^shortcut/(?P<pk>[0-9]+)$', ShortcutInfo.as_view()),
    url(r'^shortcut/(?P<pk>[0-9]+)/(?P<action>[^/]+)$', ShortcutInfo.as_view()),
)

urlpatterns += patterns('',
    url(r'^fixedips/$',FixedipList.as_view()),
    url(r'^fixedips/(?P<action>[^/]+)$',FixedipList.as_view()),
    url(r'^fixedip/(?P<action>[^/]+)$',FixedipInfo.as_view()),
    url(r'^fixedip/(?P<pk>[0-9]+)/(?P<action>[^/]+)$', FixedipInfo.as_view()),
)


urlpatterns += patterns('',
    url(r'^users/$',Users.as_view()),
    url(r'^users/(?P<action>[^/]+)$',Users.as_view()),
    url(r'^user/(?P<pk>[0-9]+)/(?P<action>[^/]+)$',UserInfo.as_view()),
)

urlpatterns += patterns('',
    url(r'^client/(?P<action>[^/]+)',Client.as_view()),
    url(r'^user/(?P<action>[^/]+)$',Client.as_view()),
    url(r'^user/(?P<action>[^/]+)$',Client.as_view()),
)

urlpatterns += patterns('',
    url(r'^license$', License.as_view())
)

